import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { treeData } from '/@/views/demo/tree/data';

export const columns: BasicColumn[] = [
  {
    title: "商品编号",
    dataIndex: "id",
    width: 180,
  },
  {
    title: "商品名称",
    dataIndex: "goodsName",
    minWidth: 200,
    //slot: "goodsSlot",
  },
  {
    title: "销售模式",
    dataIndex: "salesModel",
    width: 100,
    // render: (h, params) => {
    //   if (params.row.salesModel === "RETAIL") {
    //     return h("Tag", { props: { color: "orange" } }, "零售");
    //   } else if (params.row.salesModel === "WHOLESALE") {
    //     return h("Tag", { props: { color: "magenta" } }, "批发");
    //   } else {
    //     return h("Tag", { props: { color: "volcano" } }, "其他类型");
    //   }
    // },
  },
  {
    title: "商品类型",
    dataIndex: "goodsType",
    width: 130,
    // render: (h, params) => {
    //   if (params.row.goodsType === "PHYSICAL_GOODS") {
    //     return h("Tag", { props: { color: "geekblue" } }, "实物商品");
    //   } else if (params.row.goodsType === "VIRTUAL_GOODS") {
    //     return h("Tag", { props: { color: "purple" } }, "虚拟商品");
    //   } else {
    //     return h("Tag", { props: { color: "cyan" } }, "电子卡券");
    //   }
    // },
  },
  {
    title: "商品价格",
    dataIndex: "price",
    width: 130,
    // render: (h, params) => {
    //   return h("priceColorScheme", {props:{value:params.row.price,color:this.$mainColor}} );
    // },
  },
  {
    title: "库存",
    dataIndex: "quantity",
    width: 120,
    // render: (h, params) => {
    //   if (params.row.quantity) {
    //     return h("div", params.row.quantity);
    //   } else {
    //     return h("div", 0);
    //   }
    // },
  },
  {
    title: "审核状态",
    dataIndex: "authFlag",
    width: 120,
    // render: (h, params) => {
    //   if (params.row.authFlag == "PASS") {
    //     return h("Tag", { props: { color: "green" } }, "通过");
    //   } else if (params.row.authFlag == "TOBEAUDITED") {
    //     return h("Tag", { props: { color: "volcano" } }, "待审核");
    //   } else if (params.row.authFlag == "REFUSE") {
    //     return h("Tag", { props: { color: "red" } }, "审核拒绝");
    //   }
    // },
  },
  {
    title: "上架状态",
    dataIndex: "marketEnable",
    width: 130,
    // render: (h, params) => {
    //   if (params.row.marketEnable == "DOWN") {
    //     return h("Tag", { props: { color: "red" } }, "下架");
    //   } else if (params.row.marketEnable == "UPPER") {
    //     return h("Tag", { props: { color: "green" } }, "上架");
    //   }
    // },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '删除标志 true/false 删除/未删除',
    field: 'deleteFlag',
    component: 'Input'
  },
  {
    label: '佣金比例',
    field: 'commissionRate',
    component: 'InputNumber'
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  { label: '', field: 'parentId', component: 'Input', show: false },
  { label: '', field: 'level', component: 'Input', show: false },
  {
    label: '上级分类',
    field: 'parentTitle',
    component: 'Input',
    dynamicDisabled: true,
    colProps: { span: 21 }
  },
  {
    label: '分类名称',
    field: 'name',
    component: 'Input',
    colProps: { span: 21 }
  },
  {
    label: '排序值',
    field: 'sortOrder',
    component: 'InputNumber',
    colProps: { span: 21 }
  },
  {
    label: '状态',
    field: 'deleteFlag',
    component: 'Switch',
    defaultValue: true,
    componentProps: {
      checkedChildren: '是',
      unCheckedChildren: '否',
    },
    colProps: { span: 21 }
  },
];
